package com.dts.listener;

import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

import java.text.SimpleDateFormat;
import java.util.Date;

@WebListener
public class MyHttpSessionListener implements HttpSessionListener {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println(sdf.format(new Date()) + " session has create, id is " + se.getSession().getId());
    }
    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println(sdf.format(new Date()) + " session has destroyed ... ");
    }
}
